import Vue from 'vue'
import VueRouter from 'vue-router'

const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)

const routes = [{
    path: '',
    redirect: '/login', //重定向   默认首页
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('views/login/Login.vue')
  },
  {
    path: '/main',
    component: () => import('views/Main.vue'),
    redirect: '/main/sy',
    children: [
      {
        path: 'sy',
        component: () => import('views/main/sy/Sy.vue'),
        children: [
          {
            path: '/',
            redirect: 'sync'
          },
          {
            path: 'sync',
            name: 'sync',
            component: () => import('views/main/sy/syPage/SyNc.vue')
          },
          {
            path: 'synm',
            name: 'synm',
            component: () => import('views/main/sy/syPage/SyNm.vue')
          },
          {
            path: 'syny',
            name: 'syny',
            component: () => import('views/main/sy/syPage/SyNy.vue')
          }
        ]
      },
      {
        path: 'ksy',
        component: () => import('views/main/ksy/Ksy.vue'),
        children: [
          {
            path: '/',
            redirect: 'ksyMain'
          },
          {
            path: 'ksyMain',
            component: () => import('views/main/ksy/ksyPage/KsyMain.vue'),
            children: [
              {
                path: '/',
                redirect: 'peoples'
              },
              {
                name: 'peoples',
                path: 'peoples',
                component: () => import('views/main/ksy/ksyPage/pages/People.vue')
              },
              {
                name: 'industry',
                path: 'industry',
                component: () => import('views/main/ksy/ksyPage/pages/Industry.vue')
              },
              {
                name: 'partyBuilding',
                path: 'partyBuilding',
                component: () => import('views/main/ksy/ksyPage/pages/PartyBuilding.vue')
              }
            ]
          }
        ]
      },
      {
        path: 'iot',
        name: 'iot',
        component: () => import('views/main/iot/Iot.vue')
      },
      {
        path: 'ffp',
        name: 'ffp',
        component: () => import('views/main/day/Ffanpin.vue')
      }
    ]
  },
  {
    path: '*',
    component: () => import('../views/notFound/NotFound.vue')
  }
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

export default router
